<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>提莫攻击</title>
</head>

<body>
  <script>


    function find(timeSeries, duration) {
      let min = 0;
      let time = 0;
      for (let i = 0; i < timeSeries.length - 1; i++) {
        min = timeSeries[i + 1] - timeSeries[i];
        if (min >= duration)
          time += duration;
        else
          time += min;
      }
      time += duration;
      return time;
    };
    console.log(find(timeSeries = [1, 5], duration = 2));

  </script>
</body>

</html>